﻿using Spring.Context;
using Spring.Context.Support;
using log4net;
using System.Configuration;
using log4net.Appender;
using log4net.Core;
using System;
using Harkon.AppServer.cOne.Service;
using System.ServiceProcess;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace Harkon.AppServer.cOne
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Define working directory (For a service, this is set to System)
            Process pc = Process.GetCurrentProcess();
            Directory.SetCurrentDirectory(pc.MainModule.FileName.Substring(0, pc.MainModule.FileName.LastIndexOf(@"\")));
            
            if (args == null || args.Length==0)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] 
			    { 
				    new COneService() 
			    };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                COneService service = new COneService();
                service.ManualStart();
                Console.WriteLine("cOne AppServer up and running...");
                Console.ReadLine();
                service.ManualStop();
            }
        }
    }
}
